/**
 * 一级线型
 */
function LineView() {
    this.base = Shape;
    this.base();
    this.step = G.canvas.config.step;
    this.setZIndex(-G.canvas.getZIndex());
}
LineView.prototype = new Shape();

LineView.prototype.toString = function() {
	return '[Component Shape LineView]';
};
LineView.prototype.render = function(canvas, from, to) {
	if (!canvas) canvas = document;
	this.setCoordinate(from, to);
	canvas.appendChild(this.getUI());
};
LineView.prototype.setFrom = function (point) {
    if (!point) {
        return;
    }
    this.fromPoint = point;
    this.getUI().from = point.getX() + "," + point.getY();
};
LineView.prototype.setTo = function (point) {
    if (!point) {
        return;
    }
    this.toPoint = point;
    this.getUI().to = point.getX() + "," + point.getY();
};

LineView.prototype.getFromPoint = function () {
    return this.fromPoint;
};
LineView.prototype.getToPoint = function () {
    return this.toPoint;
};
LineView.prototype.setCoordinate = function(from, to) {
	this.setFrom(from);
	this.setTo(to);
	
	var path = '';
	var fx = parseInt(this.fromPoint.getX());
	var fy = parseInt(this.fromPoint.getY());
	var tx = parseInt(this.toPoint.getX());
	var ty = parseInt(this.toPoint.getY());
	path += 'm' + tx + ',' + ty + ' l' + tx + ',' + ty + ', ';
	path += fx + ((tx>fx) ? -this.step : this.step) + ',';
	path += fy + ((ty>fy) ? this.step : -this.step) + ',';
	path += fx + ((tx>fx) ? this.step : -this.step) + ',';
	path += fy + ((ty>fy) ? -this.step : this.step) + ' xe';
	this.setPath(path);
};